package org.heydr.example;


import org.heydr.Crawler;
import org.heydr.common.Config;
import org.heydr.concurrent.CrawlerEngine;
import org.heydr.concurrent.CrawlerEngine.CrawlerGenerator;
import org.heydr.data.ResourceEngine;
import org.heydr.example.crawler.MyCrawler;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class Slaver {
	
	private static ResourceEngine resourceEngine;
	
	public static void main(String[] args) {
		
		ApplicationContext ctx = new ClassPathXmlApplicationContext("slaver.xml");
		resourceEngine = (ResourceEngine)ctx.getBean("resourceEngine");
		
		// init crawler
		Config config = new Config();
		CrawlerEngine.go(config,resourceEngine,new CrawlerGenerator() {
			@Override
			public Crawler generateCrawler() {
				return new MyCrawler(resourceEngine);
			}
		});
	}
}
